<template>
  <view class="u-page">
    <u-navbar back-text="返回" title="维修审核"  :custom-back="customBack"></u-navbar>
<!--    <view style="font-size: 26rpx;color: red;text-align: center;padding-bottom: 10rpx">表单填写完成但未上传材料的申报信息将存在草稿箱中</view>-->
    <u-subsection style="margin-top: 1px;" :list="list" :current="workstatus" mode="subsection" :active-color="'#2979ff'" @change="getList"></u-subsection>
    <view class="list-box"  v-if="JSON.stringify(indexList) != '[]'">
      <view class="applicant-list" v-for="(item,index) in indexList" :key="index" @click="toDeclare(item)">
        <view class="applicant-list-name">
          <text class="applicant-list-item">{{ item.building + '-' + item.roomId}}</text>
          {{ item.repairsName }}
        </view>
        <view class="applicant-list-name applicant-list-idcard">
          电话：{{ item.phoneNumber }}
        </view>
        <view class="applicant-list-name applicant-list-idcard">
          报修项目：{{ repairsProject(item.repairsProject) }}
        </view>
      </view>
    </view>
    <u-empty
      v-else
      style="padding-top: 400rpx"
      mode="data"
      icon="http://cdn.uviewui.com/uview/empty/data.png"
    >
    </u-empty>
    <u-loading-page :loading="isloadPage" icon-size="36" ></u-loading-page>
  </view>
</template>

<script>
// import {getAssociationList, getZcInfo, nightlistMy} from "../../api/sever";

export default {
  data() {
    return {
      list:['维修申请','维修完成'],
      workstatus:'0',
      indexList: [],
      isloadPage:false,
      openId:uni.getStorageSync("openId") ,
      activeType:0,
      contactRelationList:[]
    }
  },
  async onLoad(option) {
    this.activeType = option.type
    this.contactRelationList = []
    let res = await this.$api.dormitory.getdictType('repairs_project');
    let data2 = res.data
    if (data2) {
      data2.forEach(item => {
        this.contactRelationList.push({ value: item.dictValue, label: item.dictLabel })
      })
    }
    this.init()
    this.getList('0')

  },
  methods: {
    repairsProject(v){
      let str = ''
      this.contactRelationList.forEach(k => {
        if (k.value == v) {
          str = k.label
        }
      })
      return str
    },
    customBack(){
      uni.reLaunch({
        url: `/pages/serve/webIndex`
      })
    },
    init(){

    },
    async getList(index){
      this.activeType = index
      uni.showLoading({
        title: '加载中...',
        mask: true,
      });

      let {rows} = await this.$api.dormitory.picturelist(this.openId,index?index:'0').catch(e=>{
        uni.hideLoading();
      })
      uni.hideLoading();
      this.indexList = rows
    },
    toDeclare(item){
      uni.navigateTo({
        url: '/pages/HomePage/warrantyAudit/webIndex?id='+item.id+'&isSuccess='+this.activeType
      });
    },
  },
}
</script>

<style scoped lang="scss">
.applicant-list{
  padding: 30rpx;
  padding-bottom:15rpx;
  border-bottom: 2px solid #dddddd;
  //border-top: 2px solid #dddddd;
  font-size: 28rpx;
  position: relative;
  view{
    padding-left: 30rpx;
}
  .applicant-list-name{
    padding-bottom: 15rpx;
    text{
      font-size: 26rpx;
      color: #5e89c2;
      background: #e3edf9;
      border-radius: 20rpx;
      padding: 4rpx 18rpx;
      margin-right: 8rpx;
  }

}
  .applicant-list-idcard{
    color: #949494;
}
  .applicant-list-btn{
    display: flex;justify-content: flex-end;
    align-items: center;
    .u-button{
      width: 60rpx;
      margin:0 10rpx;
      height: 50rpx;
  }
}
}
</style>
